<?php
require_once "../Common/database.php";
require_once "../Common/values.php";
$user = $HTTP_COOKIE_VARS["user"];
#$datelog=$datelog.'%';
$result1="SELECT * FROM tblJobs WHERE LogNumber LIKE '%$datelog%' ORDER BY LogNumber DESC";
$result = mysql_query($result1);
$logid = 1;
#$logtemp =$datelog.$logid ;
$dateloglimit = $datelog+1 ;
$dateloglimit=$dateloglimit.'0';
#echo '<p>result '.$dateloglimit;
#$datelog=date("dmy", time());
$row = mysql_fetch_array($result);

#echo '<p>row '.$row['LogNumber'];
#echo '<p>'.$logid;


if ($date==$row['Date'])
{


$Log=$row['LogNumber']+1;
if ($Log==$dateloglimit)
{
$Log=$datelog.'10';
}
#echo '<p>SQL Row Date : '.$row['Date'];
#echo '<p>'.$Log;

#$logtemp =$datelog.$logid ;  
}
else
{
$Log=$datelog.$logid ;

}
#if ($Log==$dateloglimit)
#{
#$Log=$datelog.'10';
#}

#echo '<p>log temp :'.$logtemp;
#$logtemp =$datelog.$logid ;


#$Log=$logtemp;
#echo '<p>Log : '.$Log ;

if($_POST['DeskPhone']!='')
{
    $order=$order.'Desk phone : '.$_POST['DeskPhone'].'
';
}
if($_POST['WalkaboutPhone']!='')
{
    $order=$order.'Walkabout phone : '.$_POST['WalkaboutPhone'].'
';
}
if($_POST['Headed']!='')
{
    $order=$order.'Header Paper : '.$_POST['Headed'].'
';
}
if($_POST['BilledDept']!='')
{
    $order=$order.'Billing Department : '.$_POST['BilledDept'].'
';
}
if($_POST['BillingDetails']!='')
{
    $order=$order.'BillingDetails : '.$_POST['BilledDetails'].'
';
}
if($_POST['OtherInfo']!='')
{
    $order=$order.'Other Info : '.$_POST['OtherInfo'].'
';
}
$_POST[problem]='Consumable Order :
'.$order;
#$_POST[requested]=$_POST['Requestedby'];

$result=mysql_query("SELECT * FROM tblstatus WHERE Name='$_POST[status]'");
$row = mysql_fetch_array($result);

$query="INSERT INTO tblJobs  VALUES ('$Log','Public','$_POST[requestor]','Consumable Request','$time','$date','low','1','Pending','$_POST[problem]','$_POST[Site]','$_POST[Department]','$_POST[phone]','','$_POST[DateRequired]','Not Assigned','','','Consumable','','')";
#echo $query;
$_POST[subject]='Consumable Request';
mysql_query($query);
$_POST[mail]='new';
require "../Common/mail.php";
mysql_close();
echo '<center><h2>Job Logged ';
echo '<p>Log number '; echo $Log;

echo '<p><a href="http://192.168.14.91/vis">Back</a>';

?>